# -*- coding: utf-8 -*-

import string

plaintext_ = string.ascii_lowercase
ciphertext_ = string.ascii_uppercase

#加密算法

def encryption(plaintext):
    cipherarr = [0 for i in range(len(plaintext))]
    plaintext_list = list(plaintext)

    j = 0
    for plaintext_item in plaintext_list:
        for i in range(len(plaintext_)):
            if plaintext_item == plaintext_[i]:
                ciphertext = (11*i+4)%26
                cipherarr[j] = ciphertext_[ciphertext]
                j = j+1

    cipher = ''.join(cipherarr)
    return cipher  

# 解密算法
def decryption(ciphertext):
    plaintext_arr = [0 for i in range(len(ciphertext))]
    cipherlist = list(ciphertext)

    j = 0
    for cipheritem in cipherlist:
        for i in range(len(ciphertext_)):
            if cipheritem == ciphertext_[i]:
                plaintext = (19*i-24)%26
                plaintext_arr[j] = plaintext_[plaintext]
                j = j+1

    plain = ''.join(plaintext_arr)
    return plain

print "请选择加密或解密，加密输入e，解密输入d"
a = raw_input()
if a == "e":
    plaintext = raw_input('请输入明文：')
    cipher = encryption(plaintext)
    print '密文是:',cipher
elif a == "d":
    ciphertext = raw_input('请输入密文：')
    plain = decryption(ciphertext)
    print '明文输出为：',plain
else:
    print "输入的字母有误"